home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / thinkref / archive / THINKPascalUH2.1.sea / THINKPas Univ Hdr 2.1 / Interfaces / CodeFragments.p < prev    next >
Text File  |  1995-09-12  |  8KB  |  290 lines

  1. { Converted with MPW2TPas Tuesday, September 12, 1995 5:27:52 PM }
  2. {
  3.      File:        CodeFragments.p
  4.  
  5.      Contains:    Code Fragment Manager Interfaces.
  6.  
  7.      Version:    Technology:    System 7.5
  8.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. }
  20.  
  21.  UNIT CodeFragments;
  22.  INTERFACE
  23.  
  24.  
  25. {$IFC UNDEFINED __CODEFRAGMENTS__}
  26. {$SETC __CODEFRAGMENTS__ := 1}
  27.  
  28.   USES
  29.    ConditionalMacros, Types, Files;
  30.  
  31. { $PUSH}
  32. { $ALIGN MAC68K}
  33. { $LibExport+}
  34.  
  35. CONST
  36.     kCFragResourceType            = 'cfrg';
  37.     kCFragResourceID            = 0;
  38.     kCFragLibraryFileType        = 'shlb';
  39.  
  40.     
  41. TYPE
  42.     CFragArchitecture = OSType;
  43.  
  44.  
  45. CONST
  46.     kPowerPCCFragArch            = 'pwpc';
  47.     kMotorola68KCFragArch        = 'm68k';
  48.     kAnyCFragArch                = $3F3F3F3F;
  49.  
  50. {$IFC GENERATINGPOWERPC }
  51.     kCurrentCFragArch            = kPowerPCCFragArch;
  52.  
  53. {$ENDC}
  54. {$IFC GENERATING68K }
  55.     kCurrentCFragArch            = kMotorola68KCFragArch;
  56.  
  57. {$ENDC}
  58.     
  59. TYPE
  60.     CFragConnectionID = UInt32;
  61.  
  62.     CFragClosureID = UInt32;
  63.  
  64.     CFragContextID = UInt32;
  65.  
  66.     CFragContainerID = UInt32;
  67.  
  68.     
  69. TYPE
  70.     CFragLoadOptions = UInt32;
  71.  
  72.  
  73. CONST
  74.     kLoadCFrag                    = $01;                            { Try to use existing copy, load if not found.}
  75.     kFindCFrag                    = $02;                            { Try find an existing copy, don't load if not found.}
  76.     kNewCFragCopy                = $05;                            { Load a new copy whether one already exists or not.}
  77.     kInplaceCFrag                = $80;                            { Use data sections directly in the container.}
  78.  
  79.     kUnresolvedCFragSymbolAddress = 0;
  80.  
  81.     
  82. TYPE
  83.     CFragSymbolClass = UInt8;
  84.  
  85.  
  86. CONST
  87.     kCodeCFragSymbol            = 0;
  88.     kDataCFragSymbol            = 1;
  89.     kTVectorCFragSymbol            = 2;
  90.     kTOCCFragSymbol                = 3;
  91.     kGlueCFragSymbol            = 4;
  92.  
  93.     
  94. TYPE
  95.     CFragUsage = UInt8;
  96.  
  97.  
  98. CONST
  99.     kImportLibraryCFrag            = 0;                            { Standard CFM import library.}
  100.     kApplicationCFrag            = 1;                            { Macintosh application.}
  101.     kDropInAdditionCFrag        = 2;                            { Private extension to an application or library.}
  102.  
  103.     kIsCompleteCFrag            = 0;                            { A "base" fragment, not an update.}
  104.     kFirstCFragUpdate            = 1;                            { The first update, others are numbered 2, 3, ...}
  105.  
  106.     
  107. TYPE
  108.     CFragLocatorKind = UInt8;
  109.  
  110.  
  111. CONST
  112.     kMemoryCFragLocator            = 0;                            { Container is already addressable.}
  113.     kDataForkCFragLocator        = 1;                            { Container is in a file's data fork.}
  114.     kResourceCFragLocator        = 2;                            { Container is in a file's resource fork.}
  115.     kByteStreamCFragLocator        = 3;                            { Container is in a given file fork as a byte stream.}
  116.  
  117.     kCFragGoesToEOF                = 0;
  118.  
  119.  
  120. TYPE
  121.     CFragOldMemoryLocator = PACKED RECORD
  122.         address:                LogicalAddress;
  123.         length:                    UInt32;
  124.         inPlace:                BOOLEAN;
  125.         reserved3a:                ARRAY [0..2] OF UInt8;                    { ! Do not use this!}
  126.     END;
  127.  
  128.     CFragHFSDiskFlatLocator = RECORD
  129.         fileSpec:                FSSpecPtr;
  130.         offset:                    UInt32;
  131.         length:                    UInt32;
  132.     END;
  133.  
  134. { ! This must have a file specification at the same offset as a data fork locator!}
  135.     CFragHFSSegmentedLocator = PACKED RECORD
  136.         fileSpec:                FSSpecPtr;
  137.         rsrcType:                OSType;
  138.         rsrcID:                    SInt16;
  139.         reserved2a:                UInt16;                                    { ! Do not use this!}
  140.     END;
  141.  
  142.     CFragHFSLocator = RECORD
  143.         where:                    SInt32;                                    { Really of type CFragLocatorKind.}
  144.         CASE INTEGER OF
  145.         0: (
  146.             onDisk:                        CFragHFSDiskFlatLocator;            { First so debugger shows this form.}
  147.            );
  148.         1: (
  149.             inMem:                        CFragOldMemoryLocator;
  150.            );
  151.         2: (
  152.             inSegs:                        CFragHFSSegmentedLocator;
  153.            );
  154.     END;
  155.  
  156.     CFragHFSLocatorPtr = ^CFragHFSLocator;
  157.  
  158. { -------------------------------------------------------------------------------------------}
  159. { The parameter block passed to fragment initialization functions.  The locator and name}
  160. { pointers are valid only for the duration of the initialization routine.  I.e. if you want}
  161. { to save the locator or name, save the contents, not the pointers.  Initialization routines}
  162. { take one parameter, a pointer to the parameter block, and return a success/failure result.}
  163. { ! Note that the initialization function returns an OSErr.  Any result other than noErr will}
  164. { ! cause the entire load to be aborted at that point.}
  165.     CFragInitBlock = RECORD
  166.         contextID:                CFragContextID;
  167.         closureID:                CFragClosureID;
  168.         connectionID:            CFragConnectionID;
  169.         fragLocator:            CFragHFSLocator;
  170.         libName:                StringPtr;
  171.         reserved4a:                UInt32;                                    { ! Do not use this!}
  172.         reserved4b:                UInt32;                                    { ! Do not use this!}
  173.         reserved4c:                UInt32;                                    { ! Do not use this!}
  174.         reserved4d:                UInt32;                                    { ! Do not use this!}
  175.     END;
  176.  
  177.     CFragInitBlockPtr = ^CFragInitBlock;
  178.  
  179.     CFragInitFunction = ProcPtr;  { FUNCTION ((CONST)VAR theInitBlock: CFragInitBlock): OSErr; }
  180.  
  181.     CFragTermRoutine = ProcPtr;  { PROCEDURE ; }
  182.  
  183.     CFragInitFunctionPtr = ^CFragInitFunction;
  184.  
  185.     CFragTermRoutinePtr = ^CFragTermRoutine;
  186.  
  187. { §}
  188. { ===========================================================================================}
  189. { Routines}
  190. { ========}
  191.  
  192. FUNCTION GetSharedLibrary(libName: ConstStr63Param; archType: OSType; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  193.     {$IFC NOT GENERATINGCFM}
  194.     INLINE $3F3C, $0001, $AA5A;
  195.     {$ENDC}
  196. FUNCTION GetDiskFragment({CONST}VAR fileSpec: FSSpec; offset: UInt32; length: UInt32; fragName: ConstStr63Param; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  197.     {$IFC NOT GENERATINGCFM}
  198.     INLINE $3F3C, $0002, $AA5A;
  199.     {$ENDC}
  200. FUNCTION GetMemFragment(memAddr: UNIV Ptr; length: UInt32; fragName: ConstStr63Param; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  201.     {$IFC NOT GENERATINGCFM}
  202.     INLINE $3F3C, $0003, $AA5A;
  203.     {$ENDC}
  204. FUNCTION CloseConnection(VAR connID: CFragConnectionID): OSErr;
  205.     {$IFC NOT GENERATINGCFM}
  206.     INLINE $3F3C, $0004, $AA5A;
  207.     {$ENDC}
  208. FUNCTION FindSymbol(connID: CFragConnectionID; symName: ConstStr255Param; VAR symAddr: Ptr; VAR symClass: CFragSymbolClass): OSErr;
  209.     {$IFC NOT GENERATINGCFM}
  210.     INLINE $3F3C, $0005, $AA5A;
  211.     {$ENDC}
  212. FUNCTION CountSymbols(connID: CFragConnectionID; VAR symCount: LONGINT): OSErr;
  213.     {$IFC NOT GENERATINGCFM}
  214.     INLINE $3F3C, $0006, $AA5A;
  215.     {$ENDC}
  216. FUNCTION GetIndSymbol(connID: CFragConnectionID; symIndex: LONGINT; VAR symName: Str255; VAR symAddr: Ptr; VAR symClass: CFragSymbolClass): OSErr;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $3F3C, $0007, $AA5A;
  219.     {$ENDC}
  220. {$IFC OLDROUTINENAMES }
  221.     
  222. TYPE
  223.     ConnectionID = CFragConnectionID;
  224.  
  225.     LoadFlags = CFragLoadOptions;
  226.  
  227.     SymClass = CFragSymbolClass;
  228.  
  229.     MemFragment = CFragOldMemoryLocator;
  230.  
  231.     DiskFragment = CFragHFSDiskFlatLocator;
  232.  
  233.     SegmentedFragment = CFragHFSSegmentedLocator;
  234.  
  235.     FragmentLocator = CFragHFSLocator;
  236.  
  237.     FragmentLocatorPtr = CFragHFSLocatorPtr;
  238.  
  239.     InitBlock = CFragInitBlock;
  240.  
  241.     InitBlockPtr = CFragInitBlockPtr;
  242.  
  243.     ConnectionInitializationRoutine = CFragInitFunction;
  244.  
  245.     ConnectionTerminationRoutine = CFragTermRoutine;
  246.  
  247.  
  248. CONST
  249.     kPowerPCArch                = kPowerPCCFragArch;
  250.     kMotorola68KArch            = kMotorola68KCFragArch;
  251.     kAnyArchType                = kAnyCFragArch;
  252.     kNoLibName                    = 0;
  253.     kNoConnectionID                = 0;
  254.     kLoadLib                    = kLoadCFrag;
  255.     kFindLib                    = kFindCFrag;
  256.     kLoadNewCopy                = kNewCFragCopy;
  257.     kUseInPlace                    = kInplaceCFrag;
  258.     kCodeSym                    = kCodeCFragSymbol;
  259.     kDataSym                    = kDataCFragSymbol;
  260.     kTVectSym                    = kTVectorCFragSymbol;
  261.     kTOCSym                        = kTOCCFragSymbol;
  262.     kGlueSym                    = kGlueCFragSymbol;
  263.     kInMem                        = kMemoryCFragLocator;
  264.     kOnDiskFlat                    = kDataForkCFragLocator;
  265.     kOnDiskSegmented            = kResourceCFragLocator;
  266.     kIsLib                        = kImportLibraryCFrag;
  267.     kIsApp                        = kApplicationCFrag;
  268.     kIsDropIn                    = kDropInAdditionCFrag;
  269.     kFullLib                    = kIsCompleteCFrag;
  270.     kUpdateLib                    = kFirstCFragUpdate;
  271.     kWholeFork                    = kCFragGoesToEOF;
  272.     kCFMRsrcType                = kCFragResourceType;
  273.     kCFMRsrcID                    = kCFragResourceID;
  274.     kSHLBFileType                = kCFragLibraryFileType;
  275.     kUnresolvedSymbolAddress    = kUnresolvedCFragSymbolAddress;
  276.  
  277.     kPowerPC                    = kPowerPCCFragArch;
  278.     kMotorola68K                = kMotorola68KCFragArch;
  279.  
  280. {$ENDC}
  281.  
  282. { $ALIGN RESET}
  283. { $POP}
  284.  
  285. {$ENDC} {__CODEFRAGMENTS__}
  286.  
  287.  IMPLEMENTATION
  288.  END.
  289.  
  290.